package com.lry.basic.jvm;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class TestCPU {
    public static void main(String[] args) {
        Random random = new Random();

        List<Thread> threadList = new ArrayList<>();

        for(int i=0;i<100;i++){

            Thread t= new Thread(()->{
                for(int k=0;k<100;k++){
                    int sum = 0;
                    for(int j=0;j<1000000;j++){
                        sum += random.nextInt(2);
                    }

                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });

            threadList.add(t);
        }


        threadList.parallelStream().forEach(Thread::start);

    }
}
